
import { _decorator, Component, Node,log,Vec2,v2 } from 'cc';
import {GameCtrl} from "./GameCtrl";
const { ccclass, property } = _decorator;


const _delta = v2(0,0);

@ccclass('InputMgr')
export class InputMgr extends Component {
    // [1]
    // dummy = '';

    // [2]
    // @property
    // serializableDummy = 0;
    @property({type:GameCtrl})
    gameCtrl:GameCtrl = null;

    start () {
        // [3]
        // 注册touch事件
        this.node.on(Node.EventType.TOUCH_MOVE,this.touchMove,this);
    }

    touchMove(event){
        log("touchMove called!");
        event.getDelta(_delta);
        this.gameCtrl.onMove(_delta);
    }

    // update (deltaTime: number) {
    //     // [4]
    // }
}

/**
 * [1] Class member could be defined like this.
 * [2] Use `property` decorator if your want the member to be serializable.
 * [3] Your initialization goes here.
 * [4] Your update function goes here.
 *
 * Learn more about scripting: https://docs.cocos.com/creator/3.0/manual/en/scripting/
 * Learn more about CCClass: https://docs.cocos.com/creator/3.0/manual/en/scripting/ccclass.html
 * Learn more about life-cycle callbacks: https://docs.cocos.com/creator/3.0/manual/en/scripting/life-cycle-callbacks.html
 */
